package com.caoheng.oms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * AutoSwagger2Configuration
 *
 * @author 水墨丹青
 * @date 2018/12/14 17:39
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.caoheng.oms.controller"))
                .paths(PathSelectors.any())
                .build().pathMapping("/");
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .licenseUrl("https://www.smdq-ch.cn")
                .description("集成支付运营管理后台接口文档")
                .contact(new Contact("水墨丹青", "https://www.smdq-ch.cn", "1184219041@qq.com"))
                .title("集成支付接口文档")
                .version("0.0.1")
                .build();
    }
}
